/*
 * nativeactivity2D.cpp
 *
 *  Created on: 03 Haz 2012
 *      Author: hframe
 */

#include "nativeactivity2D.h"

startnamespace(androidplus)


usenamespace(androidplus::drawing);

nativeactivity2D::nativeactivity2D(t_uint32 width,t_uint32 height) {
 act_width=width;
 act_height=height;

}

nativeactivity2D::~nativeactivity2D() {

}

void nativeactivity2D::initialize_graphics_matrix()
{
	 t_float act_width_half=1.0f*act_width/2.0f;
	 if(act_width_half==0)
		 act_width_half=get_width()/2.0f;

	 t_float act_height_half=1.0f*act_height/2.0f;
	 if(act_height_half==0)
		 act_height_half=get_height()/2.0f;

	   ui::graphics *grph= surface::grph;
	   if(get_width()<get_height())
	   	 grph->projection_matrix =new matrix(grph->ortho(-1.0f*act_width_half,1.0f*act_width_half,-1.0f*get_height()/get_width()*act_height_half,1.0f*get_height()/grph->get_width()*act_height_half,-1.0f,1.0f));
	   	 else
	   	 grph->projection_matrix =new drawing::matrix(grph->ortho(-1.0f*get_width()/get_height()*act_width_half,1.0f*get_width()/get_height()*act_width_half,-1.0f*act_height_half,1.0f*act_height_half,-1.0f,1.0f));

	   grph->camera_matrix=new matrix(matrix::matrix_identity());
	   grph->model_matrix=new matrix(matrix::matrix_identity());

}

endnamespace(androidplus)
